<?php
class LinkerHelper extends AppHelper {
	
	function userLink($user,$content=null)
	{
		$href = "/people/{$user['uid']}";
		$content = $user['username'];
		
		return "<a href='".$href."'>".$content."</a>";
		//return   $html->link($user['username'], "/people/{$user['uid']}") ;
	}
	function userManageLink($user,$content=null)
	{
		$href = "/manage/user_show?user_id={$user['id']}";
		$content = $user['username'];
		
		return "<a href='".$href."'>".$content."</a>";
	}
	
	function noteLink($note,$content=null)
	{
		$href="/notes/view/{$note['id']}";
		$content = $note['title'];
		return "<a href='".$href."'>".$content."</a>";

	}
	function notesLink($user,$content=null){
		$href = "/people/{$user['uid']}/diary";
		if (is_null($content)) {
			$content = $user['username']."的日记";
		}
		return $this->linkMaker($href,$content);
	}
	public function groupLink($group,$content=null)
	{
	    $href = "/group/{$group['gid']}";
		if (is_null($content)) {
			$content = $group['name']."小组";
		}
	    return "<a href='".$href."'>".$content."</a>";
	}
	function wordsLink($user,$content=null){
		$href = "/people/{$user['uid']}/words";
		if (is_null($content)) {
			$content = $user['username']."的单词";
		}
		return $this->linkMaker($href,$content);
	}	
	
	function linkMaker($href=null,$content=null,$title=null)
	{
		if (is_null($title)) {
				$title=$content;
		}	
		return "<a title='".$title."' href='".$href."'>".$content."</a>";
	}

        function activateLink($user) {
            if (!is_null($user)) {
                $name = $user['username'];
                $code = $user['activation_code'];
                $content = '激活邮箱>>';
                $id = $user['id'];
                $href = "http://192.168.0.59/users/activate?code=".$code;
                return "<a title='"."激活邮箱"."' href='".$href."'>".$content."</a>";
            }else{
                return 'something worng ~    :s';
            }
        }

       function passwordResetLink($user) {
           if (!is_null($user)) {
               $content = '重设密码';
               $href = "http://192.168.0.59/users/reset_password?confirmation=".$user['confirm_code'];
               return "<a title='{$content}' href= '".$href."'>".$content."</a>";
           }
       }
	

}

?>